package com.huixuebao.after.config;

import com.huixuebao.common.intercepors.JWTInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor())
                .excludePathPatterns("/app/login")
                .excludePathPatterns("/app/getSmsCode")
                .excludePathPatterns("/hzcx") //放行
                .excludePathPatterns("/hxb/after/login/**")
                .excludePathPatterns("/temp/user/**")
                .excludePathPatterns("/hxb/after/excel/**")
                .excludePathPatterns("/hxb/after/group/**")
                //放行获取地区x、y轴
                .excludePathPatterns("/hxb/after/merchants/getAreaCode")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/swagger/**")
                .excludePathPatterns("/v2/api-docs")
                .excludePathPatterns("/swagger-resources/**")
                .excludePathPatterns("/swagger-ui.html")
                .addPathPatterns("/**"); //拦截接口地址
    }

    @Bean
    public JWTInterceptor jwtInterceptor() {
        return new JWTInterceptor();
    }
}
